package core{
/**
 * @author daichangxin
 */
public class Context
{
	private var _onCommands:Array = [];
	private var _offCommands:Array = [];
	
	private var _command:ICommand;
	
	public function Context()
	{
		_command = new NoneCommand();
	}
	
	public function setCommand(slot:uint, onCommand:ICommand, offCommand:ICommand):void
	{
		_onCommands[slot] = onCommand;
		_offCommands[slot] = offCommand;
	}
	
	public function onButton_Status_ON_Press(slot:uint):void
	{
		var command:ICommand = _onCommands[slot];
		command.execute();
		
		_command = command;
	}
	
	public function onButton_Status_OFF_Press(slot:uint):void
	{
		var command:ICommand = _offCommands[slot];
		command.execute();
		
		_command = command;
	}
	
	public function undo():void
	{
		_command.undo();
	}
	
}
}
